import cherrypy
import framework.jsonencoder
import sources.helloworld
import sources.sneakypetes
import sources.thebongoclub

def json_handler(*args, **kwargs):
    value = cherrypy.serving.request._json_inner_handler(*args, **kwargs)
    return framework.jsonencoder.JSONEventEncoder().iterencode(value)

class EventService(object):

    @cherrypy.expose
    @cherrypy.tools.json_out()
    def helloworld(self):
        return sources.helloworld.get_events()

    @cherrypy.expose
    @cherrypy.tools.json_out()
    def sneakypetes(self):
        return sources.sneakypetes.get_events()

    @cherrypy.expose
    @cherrypy.tools.json_out()
    def thebongoclub(self):
        return sources.thebongoclub.get_events()

def main():
    cherrypy.config['tools.json_out.handler'] = json_handler
    cherrypy.quickstart(EventService())

if __name__ == '__main__':
    main()